//
//  RoomStatesObject.m
//  IReceive
//
//  Created by Soyu on 12-5-10.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RoomStatesObject.h"
#import "UIColor+MLPFlatColors.h"

@implementation RoomStatesObject

- (id)init
{
    self = [super init];

    if (self)
    {
        self.RoomStates = [[NSMutableArray alloc] init];
    }

    return self;
}

- (void)dealloc
{
    self.RoomStates = nil;
}

@end

@implementation RoomState

- (Room_State) room_State
{
    if ([_RoomState isEqualToString:@""] && ![self.RoomFlag isEqualToString:@"1"] && ![self.RoomFlag isEqualToString:@"6"] && ![_Room_IfBad isEqualToString:@"1"])
    {
        _StateTitle = @"空房";
        return RoomStateNone;
    }
    else if ( ([_RoomState isEqualToString:@""] || [_RoomState isEqualToString:@"R"]) && [self.RoomFlag isEqualToString:@"1"] )
    {
        _StateTitle = @"带位房";
        return RoomStateLead;
    }
    else if ([_RoomState isEqualToString:@"R"] && ![self.RoomFlag isEqualToString:@"1"])
    {
        _StateTitle = @"预订房";
        return RoomStateReserver;
    }
    else if ([_RoomState isEqualToString:@"I"])
    {
        _StateTitle = @"已开房";
        return RoomStateIn;
    }
    else if ([_RoomState isEqualToString:@"S"])
    {
        _StateTitle = @"结账房";
        return RoomStateSettle;
    }
    else if ([_RoomState isEqualToString:@"L"])
    {
        _StateTitle = @"清洁房";
        return RoomStateRetain;
    }
    else if ([_RoomState isEqualToString:@""] && [self.RoomFlag isEqualToString:@"6"])
    {
        _StateTitle = @"并台房";
        return RoomStateMerger;
    }
    else if ([_RoomState isEqualToString:@""] && [_Room_IfBad isEqualToString:@"1"])
    {
        _StateTitle = @"维修房";
        return RoomStateBad;
    }
    return 0;
}

-(NSString *)StateTitle
{
    if ([_RoomState isEqualToString:@""] && ![self.RoomFlag isEqualToString:@"1"] && ![self.RoomFlag isEqualToString:@"6"] && ![_Room_IfBad isEqualToString:@"1"])
    {
        return @"空房";
    }
    else if ( ([_RoomState isEqualToString:@""] || [_RoomState isEqualToString:@"R"]) && [self.RoomFlag isEqualToString:@"1"] )
    {
        return @"带位房";
    }
    else if ([_RoomState isEqualToString:@"R"] && ![self.RoomFlag isEqualToString:@"1"])
    {
        return @"预订房";
    }
    else if ([_RoomState isEqualToString:@"I"])
    {
        return @"已开房";
    }
    else if ([_RoomState isEqualToString:@"S"])
    {
        return @"结账房";
    }
    else if ([_RoomState isEqualToString:@"L"])
    {
        return @"清洁房";
    }
    else if ([_RoomState isEqualToString:@""] && [self.RoomFlag isEqualToString:@"6"])
    {
        return @"并台房";
    }
    else if ([_RoomState isEqualToString:@""] && [_Room_IfBad isEqualToString:@"1"])
    {
        return @"维修房";
    }
    return nil;
}

- (UIColor *) color
{
    if ([_RoomState isEqualToString:@""] && ![self.RoomFlag isEqualToString:@"1"] && ![self.RoomFlag isEqualToString:@"6"] && ![_Room_IfBad isEqualToString:@"1"])
    {
        _room_State = RoomStateNone;
        return [UIColor flatDarkWhiteColor];
    }
    else if ( ([_RoomState isEqualToString:@""] || [_RoomState isEqualToString:@"R"]) && [self.RoomFlag isEqualToString:@"1"] )
    {
        _room_State = RoomStateLead;
        return [UIColor flatBlueColor];
    }
    else if ([_RoomState isEqualToString:@"R"] && ![self.RoomFlag isEqualToString:@"1"])
    {
        _room_State = RoomStateReserver;
        return [UIColor flatGreenColor];
    }
    else if ([_RoomState isEqualToString:@"I"])
    {
        _room_State = RoomStateIn;
        return [UIColor flatRedColor];
    }
    else if ([_RoomState isEqualToString:@"S"])
    {
        _room_State = RoomStateSettle;
        return RGB(48, 129, 105);
    }
    else if ([_RoomState isEqualToString:@"L"])
    {
        _room_State = RoomStateRetain;
        return [UIColor blueColor];
    }
    else if ([_RoomState isEqualToString:@""] && [self.RoomFlag isEqualToString:@"6"])
    {
        _room_State = RoomStateMerger;
        return [UIColor flatDarkPurpleColor];
    }
    else if ([_RoomState isEqualToString:@""] && [_Room_IfBad isEqualToString:@"1"])
    {
        _room_State = RoomStateBad;
        return [UIColor brownColor];
    }
    return [UIColor clearColor];
}

@end